clear;
% Define the size of the discrete image
imageSize = 5;

% Initialize the discrete image matrix
discreteImage = zeros(imageSize, 'uint8');

% Iterate through each pixel in the discrete image
for i = 1:imageSize
    for j = 1:imageSize
        % Calculate the x and y coordinates for the current pixel
        x = (i - 1) / (imageSize - 1);
        y = (j - 1) / (imageSize - 1);
        x
        y
        
        % Calculate the intensity value for the current pixel
        intensity = x * (1 - y);
        intensity
        
        % Map the intensity value to the gray level range [0, 31]
        graylevel_1 = intensity * 31;
        graylevel_1
        grayLevel = round(graylevel_1);
        grayLevel
        
        % Assign the gray level to the current pixel in the discrete image
        j_1 = int8(imageSize - j+1);
        discreteImage(i, j_1) = grayLevel;
    end
end

discreteImage

% Display the resulting discrete image
imshow(discreteImage, [0, 31]);